var express = require('express');
var router = express.Router();
const  mongoose = require('mongoose')

/* GET home page. */
router.get('/', function(req, res, next) {


    const Cat = mongoose.model("Cat", { name: String, sex: Number });
    const kitty = new Cat(req.body);

    kitty.save().then((data) => {
        res.json(data);
    });

});

/* post home page. */
router.post('/', function(req, res, next) {


    const Cat = mongoose.model("Cat", { name: String });
    const kitty = new Cat({ name: req.body.name });

    kitty.save().then((data) => {
        res.json(data);
    });

});

module.exports = router;